Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation in regrid2.py #509

Merged
merged 1 commit into from
Jun 20, 2023
Merged

Update documentation in regrid2.py #509

merged 1 commit into from
Jun 20, 2023

Conversation

lee1043
Copy link
Collaborator

@lee1043 lee1043 commented Jun 19, 2023

Description

Following the document returns error for regridder = regrid2.Regrid2Regridder(ds.grid, output_grid) as below:

AttributeError                            Traceback (most recent call last)
Cell In[25], line 1
----> 1 regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)

File ~/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/xcdat/regridder/regrid2.py:55, in Regrid2Regridder.__init__(self, input_grid, output_grid, **options)
     13 """
     14 Pure python implementation of the regrid2 horizontal regridder from
     15 CDMS2's regrid2 module.
   (...)
     51 >>> data_new_grid = regridder.horizontal("ts", ds)
     52 """
     53 super().__init__(input_grid, output_grid, **options)
---> 55 self._src_lat = self._input_grid.bounds.get_bounds("Y")
     56 self._src_lon = self._input_grid.bounds.get_bounds("X")
     58 self._dst_lat = self._output_grid.bounds.get_bounds("Y")

AttributeError: 'str' object has no attribute 'bounds'

Which is because type(ds.grid) is str, while type(ds.regridder.grid) is xarray.core.dataset.Dataset.

Corrected commend will be

regridder = regrid2.Regrid2Regridder(ds.regridder.grid, output_grid)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

If applicable:

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass with my changes (locally and CI/CD build)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have noted that this is a breaking change for a major release (fix or feature that would cause existing functionality to not work as expected)

Following the document returns error for `regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)` as below:


```python
AttributeError                            Traceback (most recent call last)
Cell In[25], line 1
----> 1 regridder = regrid2.Regrid2Regridder(ds.grid, output_grid)

File ~/mambaforge/envs/pmp_devel_20230223/lib/python3.9/site-packages/xcdat/regridder/regrid2.py:55, in Regrid2Regridder.__init__(self, input_grid, output_grid, **options)
     13 """
     14 Pure python implementation of the regrid2 horizontal regridder from
     15 CDMS2's regrid2 module.
   (...)
     51 >>> data_new_grid = regridder.horizontal("ts", ds)
     52 """
     53 super().__init__(input_grid, output_grid, **options)
---> 55 self._src_lat = self._input_grid.bounds.get_bounds("Y")
     56 self._src_lon = self._input_grid.bounds.get_bounds("X")
     58 self._dst_lat = self._output_grid.bounds.get_bounds("Y")

AttributeError: 'str' object has no attribute 'bounds'
```

Which is because `type(ds.grid)` is `str`, while `type(ds.regridder.grid)` is `xarray.core.dataset.Dataset`. 

Corrected commend will be
```regridder = regrid2.Regrid2Regridder(ds.regridder.grid, output_grid)
```
@lee1043 lee1043 added type: docs Updates to documentation minor A minor release, includes backwards compatible changes. labels Jun 19, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jun 19, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (be3244e) 100.00% compared to head (4fdf521) 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #509   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        15           
  Lines         1517      1517           
=========================================
  Hits          1517      1517           
Impacted Files Coverage Δ
xcdat/regridder/regrid2.py 100.00% <ø> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@tomvothecoder
Copy link
Collaborator

Thanks for this PR. Feel free to assign reviewers whenever PRs are ready to get things rolling.

I'll do an initial review.

@tomvothecoder tomvothecoder self-requested a review June 20, 2023 17:38
@lee1043
Copy link
Collaborator Author

lee1043 commented Jun 20, 2023

@tomvothecoder thanks, PR is ready for review

Copy link
Collaborator

@tomvothecoder tomvothecoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lee1043 lee1043 merged commit 792cdbd into main Jun 20, 2023
@lee1043 lee1043 deleted the lee1043-patch-1 branch June 20, 2023 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor A minor release, includes backwards compatible changes. type: docs Updates to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: Correct bug in regrid2 document
3 participants